package com.weactivity.mapper;

import com.weactivity.entity.Identity;
import org.apache.ibatis.annotations.*;

@Mapper
public interface ManageUserMapper {
    @Select("select role from user_activity_role where uid = #{uid} and aid = #{aid}")
    int getNowRole(Identity identity);

    @Select("select aid from user_activity_role where uid = #{uid}")
    int getAid(int uid);

    @Delete("delete from activity_organizer where uid = #{uid} and aid = #{aid}")
    void deleteOrganizer(Identity identity);

    @Delete("delete from activity_manager where uid = #{uid} and aid = #{aid}")
    void deleteManger(Identity identity);

    @Delete("delete from activity_participants where uid = #{uid} and aid = #{aid}")
    void deleteParticipant(Identity identity);

    @Insert("insert into activity_organizer(uid, aid, power, role) " +
            "value (#{uid},#{aid},#{power},#{role})")
    void insertOrganizer(Identity identity);

    @Insert("insert into activity_manager(uid, aid, power, role) " +
            "value (#{uid},#{aid},#{power},#{role})")
    void insertManger(Identity identity);

    @Insert("insert into activity_participants(uid, aid, power, role) " +
            "value (#{uid},#{aid},#{power},#{role})")
    void insertParticipant(Identity identity);

    @Update("update user_activity_role set power = #{power},role = #{role} where uid = #{uid} and aid = #{aid}")
    void updateRole(Identity identity);

    @Insert("insert into user_activity_role(uid, aid, power, role) value " +
            "(#{uid},#{aid},#{power},#{role})")
    void addRole(Identity identity);

    @Delete("delete from user_activity_role where uid = #{uid} and aid=#{aid}")
    void deleteRole(Identity identity);
}
